<!-- 会员中心主内容区 -->
<{css src="setting.css" app="b2c" pdir="css_mini"}>
<div class="page-article">
  <!-- 个人信息 -->
  <div id="member_information" class="member-information">
    <div class="member-title">
      <h2><{t}>个人信息<{/t}></h2><p> | <{t}>请尽量完整填写您的个人信息，方便店家与您联系<{/t}>。</p>
    </div>

    <div class="member-mod">
      <{if $allowtochangeusername}>
      <form action="<{link app=b2c ctl=site_member act=change_member_name}>" method="post" class="signupin-content">
      <{else}>
      <form action="<{link app=b2c ctl=site_member act=save_setting}>" method="post" class="signupin-content">
      <{/if}>
        <ul>
          <!--
          <li class="form-item">
            <label for="" class="form-label"><{t}>货币<{/t}>：</label>
            <span class="form-act">
              <{input type=select name="currency" options=$currency.options value=$currency.value required=true}>
            </span>
          </li>
          -->
          <li class="form-item">
            <label for="" class="form-label"><em class="warn">*</em>用户名：</label>
            <{if ($mem.local && $mem.logindisplay=='true' && $mem.loginstyle=='common') || ($mem.loginstyle=='trustlogin' && $mem.logindisplay=='false')}>
              <{$mem.local}>
            <{elseif $mem.loginstyle=='trustlogin' && $mem.logindisplay=='true'}>
            <span class="form-act">
              <{input type="text" name="local_name" value=$mem.local vtype="required"}>
              <{input type="hidden" name="logindisplay" value='false'}>
            </span>
            <{else}>
            <span class="form-act">
              <{input type="text" name="local_name" value='' vtype="required"}>
            </span>
            <{/if}>
          </li>
          
          <li class="form-item">
            <label for="" class="form-label"><em class="warn">*</em> 公司名：</label>
            <input type="text" name="gcname" onBlur="Mgcname()" id="gcname" value="<{$memr_gcname}>">
            <p id="ygcname" class="yfrname" style="font-size:small; color: #CC0001"></p>
          </li>
           <li class="form-item">
            <label for="" class="form-label"><em class="warn">*</em> 法人姓名：</label>
            <input type="text" name="frname" onBlur="Mfrname()" id="frname" class="action-frname" value="<{$memr_frname}>">
            <p id="yfrname" class="yfrname" style="font-size:small; color: #CC0001"></p>
          </li>
           <li class="form-item">
            <label for="" class="form-label"><em class="warn">*</em> 法人身份证号：</label>
            <input type="text" name="idnumber" onBlur="Midnumber()" id="idnumber" class="action-idnumber" value="<{$memr_idnumber}>">
            <p id="yidnumber" class="yfrname" style="font-size:small; color: #CC0001"></p>
          </li>
         
          <div id="container" class="container">
          <li class="form-item" style="height: 70px;">
            <label for="" class="form-label"><em class="warn">*</em> 营业执照图片：</label>
          <div style="width: 302px;"><img alt="" src="<{$memr_licensep}>" style="width:100px;"></div>
          </li>
          <li class="form-item" style="height: 70px;">
            <label for="" class="form-label"><em class="warn"></em> 食品流通许可证：</label>
          <div style="width: 302px;"><img alt="" src="<{$memr_permit}>" style="width:100px;"></div>
          </li>
          </div>
          <div id="popup">
             
    <div class="bg"><img src="" alt=""/></div>
</div>
<li class="form-item">
            <label for="" class="form-label"><em class="warn"></em> 推荐业务员：</label>
         <input type="text" name="salesman" onBlur="Msalesman()" id="salesman" value="<{$memr_salesman}>"> 
         <p id="ysalesman" class="yfrname" style="font-size:small; color: #CC0001"></p>
          </li>
         
          <{foreach from=$attr item=item name="item" key='row'}>
          <li class="form-item">
            <label for="" class="form-label"><{if $item.attr_required eq 'true'}><em class="warn">*</em><{/if}><{$item.attr_name}>：</label>
            <span class="form-act" style="position: static;">
              <{assign var=vtype value=""}>
              <{if $item.attr_required eq 'true'}>
              <{if $item.attr_type =='region'}>
              <{assign var=vtype value="area"}>
              <{elseif $item.attr_type =='gender' || $item.attr_type =='checkbox'}>
              <{assign var=vtype value="onerequired"}>
              <{else}>
              <{assign var=vtype value="required"}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type =='date'}>
              <{if $item.attr_value != '0-0-0' && $item.attr_value != '--'}>
              <{assign var=value value=$item.attr_value}>
              <{/if}>
              <{if $item.attr_edit == 'true'}>
              <{input type="datepicker" name=$item.attr_column value=$value vtype=$vtype}>
              <{else}>
              <{$value}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type =='region'}>
              <{if $item.attr_edit == 'true'}>
              <{input app=ectools type="region" name=$item.attr_column value=$item.attr_value vtype=$vtype}>
              <{else}>
              <{$item.attr_value|region}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type =='gender'}>
              <{if $item.attr_edit == 'true'}>
              <{input type="gender" class="x-check" name=$item.attr_column value=$item.attr_value vtype=$vtype}>
              <{else}>
              <{$item.attr_value|gender}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type =='select'}>
              <{if $item.attr_edit == 'true'}>
              <select name="<{$item.attr_column}>" class="x-select" vtype=$vtype>
                <option value="" <{if $item.attr_value == ''}>selected="selected"<{/if}>><{t}>请选择<{/t}></option>
                <{foreach from=$item.attr_option item=option name="option"}>
                <option value="<{$option}>" <{if $item.attr_value == $option}>selected="selected"<{/if}>><{$option}></option>
                <{/foreach}>
              </select>
              <{else}>
              <{$item.attr_value}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type =='checkbox'}>
              <{if $item.attr_edit == 'true'}>
              <{foreach from=$item.attr_option item=checkbox name="checkbox"}>
              <input type="checkbox" class="x-check" name="box:<{$item.attr_column}>[]" value="<{$checkbox}>"<{if $smarty.foreach.checkbox.first}> vtype="<{$vtype}>"<{/if}><{foreach from=$item.attr_value item=checkboxvalue name="checkboxvalue"}><{if $checkboxvalue==$checkbox}> checked="checked"<{break}><{/if}><{/foreach}>>
              <label><{$checkbox}></label>
              <{/foreach}>
              <!-- <input type="hidden" name="<{$item.attr_column}>[]" value="%no%"> -->
              <{else}>
              <{$item.attr_values}>
              <{/if}>
              <{/if}>

              <{if $item.attr_type == 'text' || $item.attr_type == 'number' || $item.attr_type == 'alpha'}>
              <{if $item.attr_edit == 'true'}>
              <input  type="text" class="x-input" name="<{$item.attr_column}>" value="<{$item.attr_value}>" vtype="<{$vtype}><{if $item.attr_valtype}><{if $vtype}>&&<{/if}><{$item.attr_valtype}><{/if}>" />
              <{else}>
              <{$item.attr_value}>
              <{/if}>
              <{/if}>

            </span>
          </li>
          <li class="form-item">
            <label for="" class="form-label"><em class="warn"></em> 今年回款总额：</label>
         <input style="color:red" type="text" name="totalreturn" value="<{$totalreturn}>" readonly="readonly">￥ 
         <em class="warn"></em> 去年回款总额：
         <input style="color:red" type="text" name="totalreturn" value="<{$pre_totalreturn}>" readonly="readonly">￥
          </li>
          <{/foreach}>
          <{if $attr || !$mem.local || $allowtochangeusername || ($mem.loginstyle=='trustlogin' && $mem.logindisplay=='true')}>
          <li class="form-item-normal"><span class="form-act" style="position: static;"><button type="submit" class="btn btn-caution" rel="_request"><span><span><{t}>保 存<{/t}></span></span></button></span></li>
          <{/if}>
        </ul>
      </form>
    </div>
  </div>
</div>
<script>

//增加修改项信息验证 by.wpn
var Query = {
	    send: function(url, element, data, fn){
	        new Request({
	            url: url,
	            link: 'cancel',
	            onSuccess: function(rs) {
	                var tips = element.retrieve('tips_instance', new formTips({
	                    target: element,
	                    where: 'after',
	                    single: true,
	                    store: true,
	                    autohide: false,
	                    destroy: true
	                })).hide();
	                if(rs) {
	                    try{
	                        rs = JSON.decode(rs);
	                    } catch (e) {}
	                    if(rs.error) {
	                        if(typeof rs.error === 'string')  (rs.error, {type: 'error'});
	                    }
	                    else {
	                        if(typeof rs.success === 'string') tips.show(rs.success, {type: 'success',autohide:3});
	                    }
	                    fn&&fn.call(this, rs);
	                }
	            }
	        }).post(data);
	    }
	};
function redirect(url) {
    if(url) top.location.href = url;
}
	 
function Mgcname(){
	var gcname = document.getElementById('gcname');
	var self = this;
	var value = gcname.value;
	var ygcname = document.getElementById('ygcname');
	ygcname.set('html','');
	 Query.send('<{link app=b2c ctl=site_passport act=check_gcname}>', this, 'gcname=' + value, function(rs){ 	 
		 if(rs.error)
			 ygcname.set('html',rs.error);
    }); 
}
	 
function Mfrname(){
	var frname = document.getElementById('frname');
	var self = this;
	var value = frname.value;
	var yfrname = document.getElementById('yfrname');
	yfrname.set('html','');
	 Query.send('<{link app=b2c ctl=site_passport act=check_frname}>', this, 'frname=' + value, function(rs){ 	 
		 if(rs.error)
			 yfrname.set('html',rs.error);
    }); 
}

function Midnumber(){
	var idnumber = document.getElementById('idnumber');
	var self = this;
	var value = idnumber.value;
	var yidnumber = document.getElementById('yidnumber');
	yidnumber.set('html','');
	 Query.send('<{link app=b2c ctl=site_passport act=check_idnumber}>', this, 'idnumber=' + value, function(rs){ 	 
		 if(rs.error)
			 yidnumber.set('html',rs.error);
    }); 
}

function Msalesman(){
	var salesman = document.getElementById('salesman');
	var self = this;
	var value = salesman.value;
	var ysalesman = document.getElementById('ysalesman');
	ysalesman.set('html','');
	 Query.send('<{link app=b2c ctl=site_passport act=check_salesman}>', this, 'salesman=' + value, function(rs){ 	 
		 if(rs.error)
			 ysalesman.set('html',rs.error);
    }); 
}

    var imgs = document.getElementById("container").getElementsByTagName("img");
    var lens = imgs.length;
    var popup = document.getElementById("popup");

    for(var i = 0; i < lens; i++){
        imgs[i].onclick = function (event){
            event = event||window.event;
            var target = document.elementFromPoint(event.clientX, event.clientY);
            showBig(target.src);
        }
    }
    popup.onclick = function (){
        popup.style.display = "none";
    }
    function showBig(src){
        popup.getElementsByTagName("img")[0].src = src;
        popup.style.display = "block";
    }
    
   
</script>